package com.sims.dao.impl;

import java.sql.ResultSet;

import com.sims.dao.IStnUserDao;
import com.sims.eo.StnUser;
import com.sims.util.MySQLConnBean;

public class StnUserDaoImp implements IStnUserDao {

	@Override
	public StnUser getUserbyAccount(String userAccount) {
		// 从数据库获取对象
		StnUser stnUser = null;
		MySQLConnBean mySqlBean = new MySQLConnBean();
		try {
			mySqlBean.OpenConn();
			// 调用MySqlBean中加载JDBC驱动的方法
			String strSql = "select * from stn_user where user_account='"
					+ userAccount + "'";
			ResultSet rs = mySqlBean.executeQuery(strSql);
			while (rs.next()) {
				stnUser = new StnUser();
				stnUser.setId(rs.getLong("id"));
				stnUser.setUserAccount(userAccount);
				stnUser.setUserPassword(rs.getString("user_password"));
				stnUser.setUserName(rs.getString("user_name"));
				stnUser.setCellphone(rs.getString("cellphone"));
				stnUser.setLockFlag(rs.getString("lock_flag"));
				stnUser.setActivityStatus(rs.getString("activity_status"));
				stnUser.setCreatedDate(rs.getDate("created_date"));
				stnUser.setLastUpdateDate(rs.getDate("last_update_date"));
				break;
			}
			rs.close();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			mySqlBean.closeStmt();
			mySqlBean.closeConn();
		}
		return stnUser;
	}

}
